#ifndef OPENSERIAL
#define OPENSERIAL

#include "ui_SerialPort.h"
#include <QTimer>

const char CMD_CONNECT = 'C';
const char CMD_READSTATUS = 'S';
const char CMD_DROITE = 'D';
const char CMD_GAUCHE = 'G';
const char CMD_AVANCER = 'A';
const char CMD_RECULER = 'R';
const char CMD_ARRETER = 'X';
const char CMD_SUIVILIGNE = 'L';
const char ACK = 0xAA;
const char NACK = 0x55;
const char N_READ = 10;

class QextSerialPort;

class SerialPort : public QDialog, private Ui::SerialPort
{
	Q_OBJECT
	
	public:
		SerialPort(QWidget *parent=0);
		int receive(int count, char *bytes);
	
	private:
		QextSerialPort *serial;
		QTimer *timer;
                void autoDetect();
	private slots:
                void on_cancelButton_clicked();
                void on_openButton_clicked();
	
	public slots:
		void closePort();
		void send(int count, char *bytes);
		void checkPort();
	
	signals:
		void portOpened();
		void portClosed();
                void portFailed();
		void dataReady();
};

#endif
